
<template>
  <div v-if="visible">
    <el-dialog :visible.sync="visible"
               title="处理详情"
               :modal="false"
               class="user-dialog add-or-updata"
               width="30%"
               :before-close="closeDialog"
               :close-on-click-modal="false"
               :close-on-press-escape="false">
      <el-form :model="dataForm"
               class="label-left-form"
               ref="dataForm"
               label-position="left"
               label-width="124px">
        <el-form-item prop="orderNumber"
                      label="商户订单号：">
          <span>{{dataForm.orderNumber}}</span>
        </el-form-item>
        <el-form-item prop="jobNumber"
                      label="工号：">
          <span>{{dataForm.jobNumber}}</span>
        </el-form-item>
        <el-form-item prop="userName"
                      label="姓名：">
          <span>{{dataForm.userName}}</span>
        </el-form-item>
        <el-form-item prop="moneySum"
                      label="提现金额/元：">
          <span>{{dataForm.moneySum}}</span>
        </el-form-item>
        <el-form-item prop="treatmentState"
                      label="处理状态：">
          <el-select v-model="dataForm.treatmentState"
                     placeholder="请选择"
                     clearable>
            <el-option v-for="item in statusOptions"
                       :key="item.value"
                       :label="item.label"
                       :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="orderNumber"
                      label="第三方交易单号：">
          <el-input v-model='dataForm.oneDayQuota'
                    placeholder=''></el-input>
        </el-form-item>
        <el-form-item v-if="dataForm.treatmentState === 2"
                      prop="reasonsRefusal"
                      label="拒绝理由："
                      :rules="required()">
          <el-input type="textarea"
                    placeholder=""
                    maxlength="50"
                    :autosize="{ minRows: 2, maxRows: 8}"
                    show-word-limit
                    v-model="dataForm.reasonsRefusal"></el-input>
        </el-form-item>
      </el-form>
      <template slot="footer">
        <el-button @click="closeDialog()">{{ $t('cancel') }}</el-button>
        <el-button type="primary"
                   @click="dataFormSubmitHandle()">修改</el-button>
      </template>

    </el-dialog>
  </div>
</template>

<script>
import minFormValidate from '@/mixins/form-validate'
import mixinViewModule from '@/mixins/view-module'
import debounce from 'lodash/debounce'

export default {
  mixins: [mixinViewModule, minFormValidate],
  components: {
  },
  data () {
    return {
      mixinViewModuleOptions: {
      },
      visible: false,
      isRequest: false,
      dialogVisible: false,
      statusOptions: [
        {
          label: '待处理',
          value: 0
        },
        {
          label: '已处理',
          value: 1
        },
        {
          label: '已拒绝',
          value: 2
        }
      ],
      dataForm: {
      }
    }
  },
  computed: {
  },
  methods: {
    closeDialog () {
      this.visible = false
      this.$refs['dataForm'].resetFields()
    },
    init (data) {
      this.visible = true
      this.dataForm = data
    },
    // 表单提交
    dataFormSubmitHandle: debounce(function () {
      this.$refs.dataForm.validate(valid => {
        if (valid) {
          this.isRequest = true
          this.$http.put('/tb/withdrawDeposit/updateStatus', this.dataForm).then(({ data: res }) => {
            if (res.code !== 0) {
              return this.$message.error(res.msg)
            }
            this.$message.success('操作成功')
            this.$emit('callBack')
            this.closeDialog()
          })
        }
      })
    }, 1000, { 'leading': true, 'trailing': false })
  }
}
</script>

<style lang="scss" scoped>
</style>
